package com.filmbooks.fragment.mine.child;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.filmbooks.R;
import com.filmbooks.activity.AboutActivity;
import com.filmbooks.contract.mine.PersonalContract;
import com.zyw.horrarndoo.sdk.base.BasePresenter;
import com.zyw.horrarndoo.sdk.base.fragment.BaseMVPCompatFragment;
import com.zyw.horrarndoo.sdk.rxbus.RxBus;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * Created by heshuxiang on 2018/3/2.
 * 描述：
 * 公司：盟将威
 * 作者：heshuxiang
 * 日期：2018/3/2.
 * 工程：FilmBooks
 * 包：com.filmbooks.fragment.mine.child
 */

public class MineLowerFragment extends BaseMVPCompatFragment<PersonalContract.PresonalUpperPersenter, PersonalContract.IPersonalUpperModel> {
    @BindView(R.id.tv_btn_settings)
    TextView tvBtnSettings;
    @BindView(R.id.tv_btn_about)
    TextView tvBtnAbout;
    Unbinder unbinder;

    public static MineLowerFragment newInstance() {
        Bundle args = new Bundle();
        MineLowerFragment fragment = new MineLowerFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @NonNull
    @Override
    public BasePresenter initPresenter() {
        return null;
    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_personal_lower;
    }

    @Override
    public void initData() {
        super.initData();
        RxBus.get().register(this);
    }

    @Override
    public void onDetach() {
        super.onDetach();
        RxBus.get().unRegister(this);
    }

    @Override
    public void initUI(View view, @Nullable Bundle savedInstanceState) {

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder = ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @OnClick({R.id.tv_btn_settings, R.id.tv_btn_about})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.tv_btn_settings:
                start(MineSettingFragment.newInstance());
                break;
            case R.id.tv_btn_about:
                startActivity(new Intent(mActivity, AboutActivity.class));
                break;
        }
    }
    @Override
    public boolean onBackPressedSupport() {
        //不处理，直接丢给Activity onBackPressedSupport处理
        //若此处要拦截回退逻辑到HomeFragment，直接使用RxBus处理
        return false;
    }
}
